exports.editRedBagActivity = function (req, res) {

    //获取restful参数
    var restfulParams = req.routeInfo.restfulParams;

    //最终结果
    var resultData = {};

    //任务流创建
    async.waterfall([
            //机构模板活动
            function (cb) {
                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.searchOrganizationActivity + "/oa_id/" + restfulParams.oa_id,
                        method: 'GET',
                    },
                    function (err, data) {

                        resultData.activity = data.data;

                        cb();
                    }
                )
            },
            //红包活动内容
            function (cb) {
                if (resultData.activity.length > 0) {
                    R.SEND_HTTP(
                        req,
                        {
                            url: CORE_APIConfig.coreAPI.searchRedBagActivityContent + "/rba_oaid/" + restfulParams.oa_id,
                            method: 'GET',
                        },
                        function (err, data) {

                            resultData.redBagContent = data.data;

                            cb();
                        }
                    )
                } else {
                    resultData.redBagContent = [];
                }

            },
            //代金券
            function (cb) {
                R.SEND_HTTP(
                    req,
                    {
                        url: CORE_APIConfig.coreAPI.search_cash_coupon + "/cc_id/" + resultData.redBagContent[0].rba_cid,
                        method: 'GET',
                    },
                    function (err, data) {

                        resultData.coupon = data.data;

                        cb();
                    }
                )

            },
        ], function (err, result) {

            //返回最终拼接结果
            RES.response(res, true, resultData);

        }
    );

}